package com.example.qiandao.controller;

import com.example.qiandao.controller.requestdto.CheckinHistoryRequestDTO;
import com.example.qiandao.controller.responsedto.CheckinHistoryDTO;
import com.example.qiandao.entity.CheckinHistory;
import com.example.qiandao.service.CheckinHistoryService;
import com.example.qiandao.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/checkinhistory")
public class CheckinHistoryController {
    @Autowired
    private CheckinHistoryService checkinHistoryService;

    // 修改路径映射，避免重复路径
    @GetMapping("/checkinhistorylist/{classId}")
    public Result<List<CheckinHistoryDTO>> getCheckinHistoryByClassId(@PathVariable Long classId) {
        List<CheckinHistoryDTO> checkinHistories = checkinHistoryService.getCheckinHistoryByClassId(classId);
        return Result.success(checkinHistories);
    }

    @PostMapping("/addcheckinhistory")
    public Result<String> addCheckinHistory(@RequestBody CheckinHistoryRequestDTO requestDTO) {
        boolean success = checkinHistoryService.addCheckinHistory(requestDTO);
        return success ? Result.success("创建签到成功") : Result.error(400, "创建签到失败");
    }
    //--------------学生部分------------------------------------------------------------------------------------
    //
}